package com.nuanshui.framework.springContext;

import com.nuanshui.framework.lang.SysStringUtils;
import org.springframework.util.CollectionUtils;

public class Environment {

    public static String getCurrentProfile() {
        String profile = null;
        String[] profiles = SpringContextUtil.getApplicationContext().getEnvironment().getActiveProfiles();

        if (profiles != null && profiles.length > 0) {
            profile = profiles[0];
        }

        return profile;
    }

    public static void setRestEnv()
    {
        System.setProperty("heatedloan_rest","1");
    }

    public static boolean isRestEnv()
    {
        return SysStringUtils.isNotEmpty(System.getProperty("heatedloan_rest"));
    }

    public static boolean isAliyunEnv()
    {
        String profile=getCurrentProfile();

        return (profile.startsWith("aliyun"));
    }

    public static boolean isRelease()
    {
        String profile=getCurrentProfile();

        return (profile.equals("aliyun_release"));
    }
}
